1. Field of the Invention
The present invention relates to an image reading apparatus for reading a document image, a method of controlling the same, and a control program.
2. Description of the Related Art
FIG. 1 is a schematic block diagram of the configuration of an image reading apparatus 200.
In FIG. 1, the image reading apparatus 200 is connected to a host computer 100, and is controlled by the host computer 100. Images from the image reading apparatus 200 are displayed by the host computer 100, and are saved therein.
The host computer 100 includes a CPU (central processing unit) 101 for performing various operations, a RAM (random access memory) 102 which is used as a work area by an operating system or programs, a hard disk 103 for storing the operating system and the programs, a monitor 104, an input device 105 including a mouse and a keyboard, and an interface unit 106 for connecting the host computer 100 to an external device of the image reading apparatus 200.
The interface unit 106 comprises a serial interface, a parallel interface, a SCSI (small computer serial interface), a USB (universal serial bus) interface, and an IEEE 1394 interface.
The image reading apparatus 200 includes a contact image sensor (hereinafter referred to as “CIS”) 201, LEDs (light emitting diodes) 202 used as light sources, an LED control circuit 203, an amplifier 204, an analog-to-digital (A/D) converter circuit 205, a shading RAM 206, a shading correction circuit 207, a peak detecting circuit 208, a gamma conversion circuit 209, a buffer RAM 210, a packing/buffer RAM control circuit 211, an interface circuit 212, a motor drive circuit 213, and a motor 214.
FIG. 2 illustrates the configuration of a program stored in the host computer 100 for controlling the image reading apparatus 200. The program includes a TWAIN (Technology Without Any Interested Name) compatible application 301, a TWAIN driver 302, a device driver 303, a port driver 304, and an operating system (OS) 305.
The packing/buffer RAM control circuit 211 controls the motor 214 and the buffer RAM 210 in the following way:
Image data output from the packing/buffer RAM control circuit 211 is written to the buffer RAM 210, and the image data written is read from buffer RAM 210 to the host computer 100 via the interface circuit 212. If a speed at which data is written from the packing/buffer RAM control circuit 211 to the buffer RAM 210 is higher than a speed at which the data is read by the host computer 100 from the RAM 210, the buffer RAM 210 encounters an overflow. The packing/buffer RAM control circuit 211 checks an available space of the buffer RAM 210, and instructs the motor drive circuit 213 to stop reading the image data when the available space equals the amount of one line of the image data. When the buffer RAM 210 becomes empty again, the packing/buffer RAM control circuit 211 instructs the motor drive circuit 213 to resume reading.
Such an operation to avoid an overflow of the buffer RAM 210 is called a start/stop operation (hereinafter referred to as “SS”). When SS is effected, the reading may be resumed either at the stop position of the CIS 210 or at a position back from the stop position. If the reading is resumed at the stop position, the image may discontinue at the stop position, thereby causing degradation of image quality. If the reading is resumed at a position back from the stop position, an extra time is required before the reading can be resumed, thereby making the overall scan time slower. Such inconveniences are inevitable if SS is caused, and it is therefore necessary to minimize SS as much as possible.
Since the driving speed of the motor 214 is proportional to a speed at which the data is written to the buffer RAM 210, the device driver 303 conventionally controls the speed of the motor 214 so that a speed at which the data is written to the buffer RAM 210 from the packing/buffer RAM control circuit 211 is lower than a speed at which the data is read from the buffer RAM 210 by the host computer 100, and so that the data is written to the buffer RAM 210 at the highest speed in the above condition.
The speed of the motor 214 is controlled, assuming that the host computer 100 reads image data from the buffer RAM 210 at a constant rate. If the reading of data by the host computer 100 is interrupted, the buffer RAM 210 becomes full, thereby causing SS.
One possible reason why the reading of data by the host computer 100 is interrupted is swapping of memories. When an image is being read, the TWAIN driver 302 reserves a work area having the same size as the size of the image. If an available space of the RAM 102 is greater than the image size, the RAM 102 is used for the work area. If an available space of the RAM 102 is smaller than the image size, the work area that cannot be stored in the available space of the RAM 102 becomes a virtual memory for which the memory of the hard disk 103 is used. If the work area allocated to the hard disk 103 is accessed, swapping of memories occurs. The swapping might cause data which is being read by the host computer 100 to be interrupted depending upon the performance of the hard disk 103.